<?php
	SESSION_START();
	//echo "<img style='width:20px;height:20px;' src='../../../public/uploads/s_14697624549015.jpg'>";
?>	 
		<center>
		<SCRIPT>  
			var d = new Date();  
			document.write(d.getFullYear() + "年" +(d.getMonth() + 1) + "月" + d.getDate() + "日");  
			document.write(' 星期'+'日一二三四五六'.charAt(new Date().getDay())); 
		</SCRIPT> 
		
			<table border="1px solid #cccccc" width="1000px">
				<tr>
					<td>订单中心 UCENTER </td>
					<th colspan='10'>VIP金额累计需要订单成功且无退换换货</th>
				</tr>
				
				
				<!---------这里用WHILE,echo将SESSION中的users信息导出-------------->
			<?php	
			//六脉神剑	
			include("dbconfig.php");
			$link = @mysqli_connect(HOST,USER,PASS,DBNAME) or die("数据库连接失败");
			mysqli_set_charset($link,"utf8");			
			
			//orders
			$sql = "select * from orders where uid={$_SESSION['user']['id']}";
			//echo $sql;die;
			$result = mysqli_query($link,$sql);	

			while($row = mysqli_fetch_assoc($result)){	
				//var_dump($row);die;	
				echo "<tr>
					<td>ID</td>
					<td>订单号</td>
					<td>联系人</td>
					<td>地址</td>
					<td>电话</td>
					<td>总金额</td>	
					<td>商品名称</td>
					<td>单价</td>
					<td>数量</td>
					<td>商品图片</td>
					<td>操作</td>
				</tr>";
				echo "<tr>";
				echo "<td align=center>{$row['id']}</td>";
				echo "<td align=center>{$row['uid']}</td>";
				echo "<td align=center>{$row['linkman']}</td>";
				echo "<td align=center>{$row['address']}</td>";
				echo "<td align=center>{$row['phone']}</td>";
				echo "<td align=center>{$row['total']}</td>";
				
				
				//detail
				$sql_detail = "select * from detail where orderid={$row['id']}";
				//echo $sql_detail;die;
				$result_detail = mysqli_query($link,$sql_detail);	
				while($row_detail = mysqli_fetch_assoc($result_detail)){	
				//var_dump($row);die;
				
				//goods
				$sql_goods = "select * from goods where id={$row_detail['goodsid']}";	
				$result_goods = mysqli_query($link,$sql_goods);
				$list_goods = mysqli_fetch_assoc($result_goods);
								
				
				echo "<td align=center>{$row_detail['name']}</td>";
				echo "<td align=center>{$row_detail['price']}</td>";
				echo "<td align=center>{$row_detail['num']}</td>";
				echo "<td align=center><img style='width:30px;height:30px;' src='../../../../public/uploads/s_{$list_goods['picname']}'></td>";
				switch($row['status']){
					case '1':echo "<td align=center>等待发货</td>";break;
					case '2':echo "<td align=center><a href='../ucenter.php?action=update_order&id={$row['id']}'>确认收货</a></td>";break;
					case '3':echo "<td align=center>已收货</td>";break;
				}
				echo "</tr>";
				
			 //遍历订单内的具体商品的信息	
				// echo "<tr>";
			
				// $sql_detail = "select * from detail where orderid={$row['id']}";
				
				// //echo $sql_detail;die;
				// $result_detail = mysqli_query($link,$sql_detail);	
				// while($row_detail = mysqli_fetch_assoc($result_detail)){	
				// //var_dump($row);die;
				// $sql_goods = "select * from goods where id={$row_detail['goodsid']}";	
				// $result_goods = mysqli_query($link,$sql_goods);
				// $list_goods = mysqli_fetch_assoc($result_goods);
				// //echo $list_goods['picname'];die;
				
				// echo "<tr>
					// <td>商品名称</td>
					// <td>单价</td>
					// <td>数量</td>
					// <td>商品图片</td>
					// </tr>";
				// echo "<tr>";
				// echo "<td align=center>{$row_detail['name']}</td>";
				// echo "<td align=center>{$row_detail['price']}</td>";
				// echo "<td align=center>{$row_detail['num']}</td>";
				// echo "<td align=center><img style='width:30px;height:30px;' src='../../../../public/uploads/s_{$list_goods['picname']}'></td>";
				// echo "</tr>";
				// }	
				// echo "</tr>";
							
			 }
			}
				?>
				<!---------这里用WHILE,echo将SESSION中的DETAIL信息导出-------------->
			</table>
			
		</center>